import useSseFetch from '~/hooks/useSseFetch';

export interface SkuGenerateParams {
  platform: string;
  skuKey: string;
  temperature: number;
}
export interface TitleGenerateParams {
  platform: string;
  titleKey: string;
  temperature: number;
}
export interface SkuGenerateRes {
  skuKey: string;
  skuId: string;
}

// 1 sku 生成
export const querySkuGenerate = (params: SkuGenerateParams, onmessage: (data: any) => void) => {
  const config = useRuntimeConfig();
  return useSseFetch(`${config.public.apiBase}/goods/generate/sku?${new URLSearchParams(params as any).toString()}`, { onmessage });
};

// 2 标题生成
export const queryTitleGenerate = (params: TitleGenerateParams, onmessage: (data: any) => void) => {
  const config = useRuntimeConfig();
  return useSseFetch(`${config.public.apiBase}/goods/generate/title?${new URLSearchParams(params as any).toString()}`, { onmessage });
};
